|
|
|
|
|
|
|
To add a caption to the InputBox() function, you need to add a second parameter with the value you want to place in the title bar of the input box. See Figure 11.6 for an example of an input box with a caption. |
|
|
|
|
|
|
|
|
Figure 11.6
An inputbox with a caption. |
|
|
|
|
|
|
|
|
I recommend that you always pass in the Caption parameter, because this will help describe the input box. If you do not pass it in, Visual Basic will just use the EXE name for the caption. Heres the code that generates the input box shown in Figure 11.6: |
|
|
|
 |
|
|
|
|
Private Sub cmdCaption_Click()
Dim strName As String
strName = InputBox("Enter an Employee Name", _
"Employee Name") MsgBox "You input " & strName
End Sub |
|
|
|
|
|
|
|
|
You can specify a value that appears in the text box when the input box first appears. Just add the third parameter to the InputBox() function, and that value appears in the text box of the input box. Heres an example: |
|
|
|
 |
|
|
|
|
Private Sub cmdDefault_Click()
Dim strName As String
strName = InputBox("Enter an Employee Name", _
"Employee Name", _
"Bill Gates")
MsgBox "You input " & strName
End Sub |
|
|
|
|
|